from decimal import Decimal
from .stock_order import StockOrder

class RowData:
    
    def __init__(self, symbol: str, timestamp_ms: int, order_id: int, price: Decimal, quantity: int, is_buy: bool, is_cancel: bool) -> None:
        self.__symbol: str = symbol
        self.__timestamp_ms: int = timestamp_ms  # 时间戳，单位为毫秒
        self.__order_id: int = order_id  # 订单 ID
        self.__price: Decimal = price  # 价格，转换为浮点数
        self.__quantity: int = quantity  # 数量
        self.__is_buy: bool = is_buy  # 订单类型，买单或卖单
        self.__is_cancel: bool = is_cancel  # 是否为撤单，默认为 False

    def get_symbol(self) -> str:
        return self.__symbol
    
    def get_timestamp_ms(self) -> int:
        return self.__timestamp_ms
    
    def get_order_id(self) -> int:
        return self.__order_id
    
    def get_price(self) -> Decimal:
        return self.__price
    
    def get_quantity(self) -> int:
        return self.__quantity
    
    def get_order_type(self) -> str:
        return self.__is_buy
    
    def is_cancel(self) -> bool:
        return self.__is_cancel
    
    def to_stock_order(self) -> StockOrder:
        """将 RowData 转换为 StockOrder"""
        return StockOrder(
            order_id=self.__order_id,
            stock_symbol=self.__symbol,
            quantity=self.__quantity,
            price=self.__price,
            isbuy_order=self.__is_buy,
            create_time=self.__timestamp_ms
        )

    
